package gov.dhs.cis.soa.data;

import gov.dhs.cis.soa.Constants;
import gov.dhs.cis.soa.Utils;
import gov.dhs.cis.soa.Constants.EntityType;

import java.sql.Timestamp;


public class UseCase extends AbstractSOAData {
	public static final String STEREO_TYPE = "UseCase";

	public int id;

	public transient String modSiceIRR;
	public String unumber;
	public String uname;
	public transient String descText;
	public String status;
	public String release;
	public String busProcessName;
	public String wipt;
	public String stereotype;
	public transient Timestamp createdDt = new Timestamp(System.currentTimeMillis());
	public Description desc;
	
	@Override
	public String toString() {
		return "Usecase [id=" + id + ", number = " + unumber + ", name=" + uname + "]";
	}
	
	@Override
	public boolean equals(Object obj) {
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		UseCase other = (UseCase) obj;
		if (id == other.id && unumber.equalsIgnoreCase(other.unumber))
			return true;
		return false;
	}
	
	public void createDescription() {
		StringBuffer txt = new StringBuffer();
		if(Utils.isEmpty(descText))
			descText = "";
		txt.append(Constants.NL+"Description = " + descText);
		if(Utils.isEmpty(busProcessName))
			busProcessName = "";
		txt.append(Constants.NL+"Process Name = " + busProcessName);
		if(Utils.isEmpty(modSiceIRR))
			modSiceIRR = "";
		txt.append(Constants.NL+"Modified Since IRR = " + modSiceIRR);
		
		desc = Utils.prepareDescObj(txt.toString(), EntityType.USEC);
	}

//	public void addReferedActor(Actor actrObj) {
//		if(actrObj == null)
//			return;
//		Actor foundO = Utils.findActorById(actrObj.id, refByActors);
//		if(foundO == null)
//			refByActors.add(actrObj);
//	}
	
//	public static String getUMLId(int entityId) {
//		return EntityType.USEC + "_" + entityId;
//	}
//	public static String getUMLId(String uNumber) {
//		return EntityType.USEC + "_" + Utils.hash(uNumber.trim());
//	}
	
	@Override
	public long getId() {
		return id;
	}
	@Override
	public String getHashableId() {
		return unumber + "." + uname;
	}
	
	@Override
	public EntityType getUMLType() {
		return EntityType.USEC;
	}
}
